var path = require('path'),
    rootPath = path.normalize(__dirname + '/..'),
    mysql = require('mysql'),
    appid = 'wxb541ec9e1f14f38e',
    secret = '9a54e9db0eceaef14ca2f7376cf975c3',
    // shopKey="1qaz2wsx3edc4rfv5tgb6yhn7ujm8ik9";
    shopKey = "11111111111111111111111111111111";

/*
console.log(__dirname);
console.log(path.normalize(__dirname + '/..'));
console.log(path.normalize(__dirname, '/..'));// 没效果，和 console.log(__dirname); 一样。也就是这个方法只有一个参数。
console.log(path.join(__dirname, '/..'));
console.log(path.join(__dirname, '..'));
console.log(path.join(__dirname, '..', 'config'));
*/
// D:\project\study\express\diy\config
// D:\project\study\express\diy
// D:\project\study\express\diy\config
// D:\project\study\express\diy
// D:\project\study\express\diy
// D:\project\study\express\diy\config


var config = {
    development: {
        app: {
            ENV_CN: '开发环境',
            ENV_EN: 'development',
            PORT: 8001
        },
        option: {
            maxAge: 0,
            cookieExpiresIn: 1000 * 60 * 60 * 24 * 3,// 毫秒；
            sessionSecret: 'keyboard cat'
        },
        api: {
            origin: 'http://zhenfei.jumpcity.cn:80'
        },
        wechat: {
            appid: appid,
            secret: secret,
            shopKey: shopKey,
            getticket: null,
            serveToken: null
        }
    },
    production: {
        app: {
            ENV_CN: '生产环境',
            ENV_EN: 'production',
            PORT: 8001
        },
        option: {
            maxAge: '2 days',
            cookieExpiresIn: 1000 * 60 * 60 * 24 * 3,// 毫秒；
            sessionSecret: 'keyboard cat'
        },
        api: {
            origin: 'http://zhenfei.jumpcity.cn:80'
        },
        wechat: {
            appid: appid,
            secret: secret,
            shopKey: shopKey,
            getticket: null,
            serveToken: null
        }
    }
};

module.exports =  function(env) {
    var config2 = config[env];
    config2.app.ROOT_PATH = rootPath;
    config2.app.PUBLIC_PATH = rootPath + '/public';
    config2.app.APP_PATH = rootPath + '/app';
    config2.app.ASSET_PATH = rootPath + '/asset';
    config2.app.isDev = env === 'development';

    // 数据库
    // config2.app.connection = mysql.createConnection({
    //     host     : 'localhost',
    //     user     : 'root',
    //     password : '123456',
    //     database : 'fortest'
    // });

    return config2;
};
